{include file="index/header" /}
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" lay-filter="edit-form">
            <div class="layui-form-item">
                <label class="layui-form-label">工具标题：</label>
                <div class="layui-input-block">
                    <input type="text" name="title" lay-verify="required" placeholder="请输入工具标题"
                           autocomplete="off" class="layui-input" value="{$form.title|default=''}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">工具作者：</label>
                <div class="layui-input-block">
                    <input type="text" name="author" lay-verify="required" placeholder="请输入工具作者"
                           autocomplete="off" class="layui-input" value="{$form.author|default=''}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">工具简介：</label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" name="sub_title" lay-verify="required" placeholder="请输入工具标题">{$form.sub_title|default=''}</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">工具关键词：</label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" name="keyword" lay-verify="required" placeholder="请输入工具关键词">{$form.keyword|default=''}</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">工具地址：</label>
                <div class="layui-input-block">
                    <div class="layui-col-sm8">
                        <input type="text" name="url" lay-verify="required" placeholder="请输入工具地址,外链需要添加http(s)://"
                               autocomplete="off" class="layui-input" value="{$form.url|default=''}">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">打开方式：</label>
                <div class="layui-input-block">
                    <select name="target" lay-verify="required">
                        <option value="_self" {:isset($form.target)&&$form.target == '_self'?'selected':''}>内部跳转</option>
                        <option value="_blank" {:isset($form.target)&&$form.target == '_blank'?'selected':''}>新页面</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">图片地址：</label>
                <div class="layui-input-block">
                    <input type="text" name="img_src" lay-verify="required" placeholder="请输入图片地址"
                           autocomplete="off" class="layui-input" value="{$form.img_src|default=''}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">工具标签：</label>
                <div class="layui-input-block">
                    {volist name=":getToolsType()" id="vo"}
                    <input type="radio" name="type" lay-verify="required" value="{$vo.code}" title="{$vo.name}" {:isset($form.type)&&$form.type == $vo.code?'checked':''} lay-skin="primary">
                    {/volist}
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">排序：</label>
                <div class="layui-input-block">
                    <input type="text" name="order" lay-verify="required|number" placeholder="请输入排序"
                           autocomplete="off" class="layui-input" value="{$form.order|default='0'}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态：</label>
                <div class="layui-input-block">
                    <input type="hidden" name="status" value="0">
                    <input type="checkbox" name="status" lay-verify="required" lay-skin="switch" {:isset($form.status)&&$form.status==1?'checked':''} value="1" lay-text="显示|关闭">
                </div>
            </div>
            <div class="layui-form-item text-center">
                <button type="button" lay-submit lay-filter="save" class="pear-btn pear-btn-success"> 保 存 </button>
                <button type="button" class="pear-btn" id="close_edit"> 关 闭 </button>
            </div>
        </form>
    </div>
</div>
<script>
    layui.use(['jquery', 'select', 'form'], function () {
        var $ = jq = layui.jquery,
            S = layui.select,
            F = layui.form;
        var this_iframe = parent.layer.getFrameIndex(window.name);
        F.on('submit(save)',function (obj){
            var load = layer.load(2);
            $.post('{$page.R}/save/id/{$form.id|default=""}',obj.field,function (info){
                if(info.code){
                    layer.msg(info.msg,function (){
                        parent.layer.close(this_iframe);
                    });
                }else{
                    layer.alert(info.msg);
                }
                layer.close(load);
            },'json');
            return false;
        });

        $('#close_edit').on('click',function (){
            parent.layer.close(this_iframe);
        });
    });
</script>
{include file="index/footer" /}